import { app, BrowserWindow } from "electron";
import path from "path";

type IApp = Electron.App & { allowRendererProcessReuse: boolean };
let mainWindow: Electron.BrowserWindow | null;

function createWindow() {

  mainWindow = new BrowserWindow({
    width: 1600,
    height: 960,
    webPreferences: {
      preload: path.resolve(__dirname, "preload"),
      nodeIntegration: true,
      contextIsolation:true,
      webSecurity: true,
    },
  });

  if (process.env.NODE_ENV === "development") {
    // ...
  } else {
    // ....
  }
  mainWindow.loadFile("dist/index.html");
  mainWindow.webContents.openDevTools();

  mainWindow.on("closed", () => {
    mainWindow = null;
  });

  app.once("window-all-closed", () => app.quit());

}

app.on("ready", createWindow);
(app as IApp).allowRendererProcessReuse = true;